//
//  InfopanelView.m
//  宜居HD
//
//  Created by 张金国 on 16/5/5.
//  Copyright © 2016年 张金国. All rights reserved.
//

#ifndef kTextFieldBackgroundColor
#define kTextFieldBackgroundColor [UIColor colorWithRed:0.513 green:0.902 blue:1.000 alpha:1.000]
#endif

#ifndef kTextViewBackgroundColor
#define kTextViewBackgroundColor [UIColor colorWithRed:0.106 green:0.576 blue:0.086 alpha:1.000]
#endif


#import "InfopanelView.h"
#import "Masonry.h"


@interface InfopanelView ()

@property (nonatomic ,strong)NSArray *namesArray;

@end

@implementation InfopanelView
#pragma mark - init
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupConstraints];
    }
    return self;
}
#pragma mark - private

- (void)setupConstraints {
   
    UILabel *lastLabel = nil;
    for (int i = 0; i < 7; i++) {
        UILabel *label = [[UILabel alloc]init];
        label.text = self.namesArray[i];
        [self addSubview:label];
        if (lastLabel == nil) {
            [label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.mas_top).offset(FiveOffsetViewMargin);
                make.left.equalTo(self.mas_left).offset(TweentyOffsetViewMargin);
                make.height.equalTo(self.mas_height).multipliedBy(1/11.0f);
                make.width.equalTo(self.mas_width).multipliedBy(1/7.50f);
            }];
        }else {
             [label mas_makeConstraints:^(MASConstraintMaker *make) {
                 make.top.equalTo(lastLabel.mas_bottom).offset(FiveOffsetViewMargin);
                 make.left.equalTo(self.mas_left).offset(TweentyOffsetViewMargin);
                 make.height.equalTo(self.mas_height).multipliedBy(1/11.0f);
                 make.width.equalTo(self.mas_width).multipliedBy(1/7.50f);
             }];
        }
        lastLabel = label;
        
        if (i >= 0 && i <= 5) {
            UITextField *textField = [[UITextField alloc]init];
            textField.tag = 100 + i;
            [self addSubview:textField];
            
            [textField mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.height.equalTo(label);
                make.left.equalTo(label.mas_right).offset(FiveOffsetViewMargin);
                make.width.equalTo(label.mas_width).multipliedBy(3.0f);
            }];
            
            if (i == 0 || i == 4 || i == 5) {
                textField.enabled = NO;
            }
            
        } else {
            UITextView *textView = [[UITextView alloc]init];
            textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
            textView.layer.borderWidth = 1.0f;
            textView.layer.cornerRadius = 5.0f;
            textView.tag = 106;
            [self addSubview:textView];
            [textView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(label);
                make.left.equalTo(label.mas_right).offset(FiveOffsetViewMargin);
                make.right.equalTo(self.mas_right).offset(-TenOffsetViewMargin);
                make.bottom.equalTo(self.mas_bottom).offset(-TenOffsetViewMargin);
            }];
        }
    }
}

#pragma mark - Getter
- (NSArray *)namesArray {
    if (!_namesArray) {
        _namesArray = @[@"账     号：",@"姓     名：",@"年     龄：",@"电     话：",@"从业年限：",@"销售公司：",@"个人说明："];
    }
    return _namesArray;
}



@end
